package com.yuncheng.spcyApi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yuncheng.spcyApi.entity.SpcySqsxHymx;
import com.yuncheng.spcyApi.mapper.SpcySqsxHymxMapper;
import com.yuncheng.spcyApi.service.ISpcySqsxHymxService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import com.yuncheng.common.base.service.impl.BaseServiceImpl;

import java.util.List;

/**
 * @Description: 申请事项-会议明细
 * @Author: yuncheng
 * @Date: 2024-03-07
 * @Version: V1.0
 */
@Service
public class SpcySqsxHymxServiceImpl extends BaseServiceImpl<SpcySqsxHymxMapper, SpcySqsxHymx> implements ISpcySqsxHymxService {

    @Async(value = "asyncSimpleTask")
    @Override
    public void updateHymxByUserid(String userid, String fqmlj) {
        if (StringUtils.isBlank(userid) || StringUtils.isBlank(fqmlj)){
            return;
        }

        LambdaUpdateWrapper<SpcySqsxHymx> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(SpcySqsxHymx::getFuserid, userid);

        SpcySqsxHymx updateBean = new SpcySqsxHymx();
        updateBean.setFqmfj(fqmlj);

        update(updateBean, updateWrapper);
    }

    @Override
    public List<SpcySqsxHymx> selectHymxListByHyidAndUserId(String fhyid, String fuserid) {
        return list(new LambdaQueryWrapper<SpcySqsxHymx>()
                .eq(SpcySqsxHymx::getFhyid, fhyid)
                .eq(SpcySqsxHymx::getFuserid, fuserid)
                .orderByAsc(SpcySqsxHymx::getCreateTime));
    }
}
